<?php
namespace soa\liuyan;

use soa\client;


class cm_comment extends client
{

    /**
     * 服务地址
     * @var string
     */
    public $service_url = 'http://message.core.kuaidihelp.com/';

    /**
     * 服务名称
     * @var string
     */
    protected $service_name = 'kuaidihelp_message';


    /**
     * 获取快递员评论
     * @param $mobile
     * @param $page
     * @param $page_size
     * @return array|false
     */
    public function getList($mobile, $page, $page_size)
    {
        if (empty($mobile)) {
            return false;
        }
        return $this->get('v1/cm_comment/getList', ['mobile' => $mobile, 'page' => $page, 'page_size' => $page_size]);
    }

    /**
     *
     * 添加用户评论
     * @param $user_id
     * @param $mobile
     * @param $comment
     * @param $user_mobile
     * @return bool
     */
    public function addComment($user_id,$mobile,$comment,$user_mobile)
    {
        if (empty($mobile) || empty($comment)) {
            return false;
        }

        $data = ['user_id' => $user_id, 'mobile' => $mobile, 'comment' => $comment,'user_mobile'=>$user_mobile];
        return $this->get('v1/cm_comment/addComment', $data);
    }

    /**
     * 现在是否还能对此网点进行评价
     * @param $user_id
     * @param $mobile
     * @return int
     */
    public function isCanComment($user_id,$mobile)
    {
        if (empty($user_id) || empty($mobile)) {
            return 0;
        }

        return $this->get('v1/cm_comment/isCanComment', ['mobile' => $mobile, 'user_id' => $user_id]);
    }

    /**
     * 添加对快递员的差评好评
     * @param $user_id
     * @param $mobile
     * @param $is_good
     * @return mixed
     */
    public function addCommentBool($user_id,$mobile,$is_good)
    {

        if (empty($mobile) || empty($user_id)) {
            return false;
        }

        return $this->get('v1/cm_comment/addCommentBool', ['mobile' => $mobile, 'user_id' => $user_id,'is_good'=>$is_good]);
    }

    /**
     * 取消对快递员的差评好评
     * @param $user_id
     * @param $mobile
     * @param $is_good
     * @return mixed
     */
    public function cancelCommentBool($user_id,$mobile,$is_good)
    {
        if (empty($user_id) || empty($mobile)) {
            return false;
        }

        return $this->get('v1/cm_comment/cancelCommentBool', ['mobile' => $mobile, 'user_id' => $user_id,'is_good'=>$is_good]);
    }

    /**
     * 获取好评坏评的条数
     * @param $user_id
     * @param $mobile
     * @param $is_good
     * @return mixed
     */
    public function getBoolCount($mobile){
        if (empty($mobile)) {
            return false;
        }

        return $this->get('v1/cm_comment/getBoolCount', ['mobile' => $mobile]);
    }

    /**
     * 获取用户好评和坏评是否已经评论过
     * @param $user_id
     * @param $mobile
     * @return mixed
     */
    public function isBool($mobile,$user_id){
        if (empty($mobile) || empty($user_id)) {
            return false;
        }

        return $this->get('v1/cm_comment/isBool', ['mobile' => $mobile,'user_id'=>$user_id]);
    }
}